package com.leo;

import javafx.application.Application;
import javafx.application.ConditionalFeature;
import javafx.application.Platform;
import javafx.scene.DepthTest;
import javafx.scene.PerspectiveCamera;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

/**
 * @ClassName D3Demo
 * @Description
 * @Author wangss
 * @date 2020.07.04 18:37
 * @Version 1.0
 */
public class D3Demo extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        AnchorPane an = new AnchorPane();

        // 是否支持3D
        System.out.println(Platform.isSupported(ConditionalFeature.SCENE3D));

        Button button = new Button("button");
        button.setTranslateZ(0);

        Button button1 = new Button("button1");
        button1.setTranslateZ(300);

        Button button2 = new Button("button2");
        button2.setTranslateZ(600);

        Button button3 = new Button("button3");
        button3.setTranslateZ(800);
        // 禁用3D效果
        button3.setDepthTest(DepthTest.DISABLE);

        an.setStyle("-fx-background-color: #FFFFFF00");
        an.getChildren().addAll(button, button1, button2, button3);

        an.setDepthTest(DepthTest.ENABLE);

        Scene scene = new Scene(an, 1200, 800, true);
        scene.setCamera(new PerspectiveCamera());

        primaryStage.setScene(scene);
        primaryStage.setTitle("3D介绍");
        primaryStage.setWidth(1200);
        primaryStage.setHeight(800);
        primaryStage.show();
    }
}
